#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main()
{
    int m, n, a, b;
    //cin >> m >> n >> a >> b;
    m = 3, n = 4, a = 1, b = 2;
    int amax = m / 2;
    int ret = 0;
    int i;
    for (i = 0; i <= amax; i++)
    {
        if (n >= i)
        {
            int x = m - 2 * i;
            int y = (n - i) / 2;
            if (x >= y)
            {
                ret = max(ret, a * i + y * b);
            }
            else
            {
                ret = max(ret, a * i + x * b);

            }
        }
        else  break;

    }
    cout << ret << endl;
}